package com.cskaoyan.controller.wxcontroller;

import com.cskaoyan.bean.po.MarketGoods;
import com.cskaoyan.bean.common.BasePageInfo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.bean.chaosbean.goods.vo.WxGoodsCategoryVo;
import com.cskaoyan.bean.chaosbean.goods.vo.WxGoodsDetailVo;
import com.cskaoyan.bean.chaosbean.goods.vo.WxGoodsListVo;
import com.cskaoyan.service.wxservice.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author dengqwe
 * @datetime 2023/1/2 13:39
 * @description: TODO:
 */
@RestController
@RequestMapping("wx/goods")
public class GoodsWeChatController {
    @Autowired
    GoodsService goodsService;

    @RequestMapping("count")
    public BaseRespVo count() {
        int num = goodsService.count();
        return BaseRespVo.okYa(num);
    }

    @RequestMapping("category")
    public BaseRespVo category(Integer id) {
        WxGoodsCategoryVo data = goodsService.category(id);
        return BaseRespVo.okYa(data);
    }

    @RequestMapping("list")
    public BaseRespVo list(BasePageInfo info, Integer categoryId) {
        WxGoodsListVo data = goodsService.list(info, categoryId);
        return BaseRespVo.okYa(data);
    }

    @RequestMapping("detail")
    public BaseRespVo detail(Integer id) {
        Integer gid = id;
        WxGoodsDetailVo data = goodsService.detail(gid);
        return BaseRespVo.okYa(data);
    }

    @RequestMapping("related")
    public BaseRespVo related(Integer id) {
        CommonData<MarketGoods> data = goodsService.related(id);
        return BaseRespVo.okYa(data);
    }
}
